﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp9
{
    class 类结构
    {
        static void Main(string[] args)
        {
            UP u1 = new UP("惠普");
            Mhd m1 = new Mhd("金士顿");
            u1.Info();
            u1.Read();
            u1.Write();
            Console.WriteLine();
            m1.Info();
            m1.Read();
            m1.Write();

            Console.WriteLine();
            Computer com = new Computer("联想");

            com.Start();
            com.Usb1 = u1;
            com.Usb2 = m1;
            com.WriteData();
            com.ReadData();
            com.End();
        }
    }
    class UP : Father, IUSB
    {
        public UP(string name):base(name) { }
        public void Read()
        {
            Console.WriteLine("U盘正在读取数据中...");
        }

        public void Write()
        {
            Console.WriteLine("U盘正在写入数据中...");
        }
    }
    class Mhd : Father, IUSB
    {
        public Mhd(string name):base(name){}
        public void Read()
        {
            Console.WriteLine("移动硬盘正在读取数据中...");
        }

        public void Write()
        {
            Console.WriteLine("移动硬盘正在写入数据中...");
        }
    }
    class Computer
    {
        private IUSB usb1;
        private IUSB usb2;
        public string Brand { get; set; }
        public Computer(string brand)
        {
            this.Brand = brand;
        }
        internal IUSB Usb1 { get => usb1; set => usb1 = value; }
        internal IUSB Usb2 { get => usb2; set => usb2 = value; }
        public void Start()
        {
            Console.WriteLine("{0}开机中...", this.Brand);
        }

        public void ReadData()
        {
            this.usb1.Read();
            this.usb2.Read();
        }

        public void WriteData()
        {
            this.usb1.Write();
            this.usb2.Write();
        }

        public void End()
        {
            Console.WriteLine("{0}关机中...", this.Brand);
        }
    }
    class Father
        {
            public string Brand { get; set; }
            public Father(string brand)
            {
                this.Brand = brand;
            }
            public void Info()
            {
                Console.WriteLine("这个东西是{0}的", this.Brand);
            }
        }
    interface IUSB
        {
            void Read();

            void Write();
        }
}
